<?php
class report_summeryController extends Zend_Controller_Action
{
	
    public function init()
    {
        /* Initialize action controller here */
    	defined('BASE_URL')	|| define('BASE_URL', Zend_Controller_Front::getInstance()->getBaseUrl());
    	$tr = Application_Form_FrmLanguages::getCurrentlanguage();
    }
	public function indexAction()
	{
		if($this->getRequest()->isPost()){
			$data = $this->getRequest()->getPost();
			
			$start_date = $data["start_date"];
			$end_date = $data["end_date"];
			
			if(strtotime($end_date)+86400 > strtotime($start_date)) {
				$query = new report_Model_DbQuery();
				//$vendor_sql .= " AND p.date_order BETWEEN '$start_date' AND '$end_date'";
				$getSaleItem = $query->getSalesItem($data);
				$this->view->getsales_item = $getSaleItem;
				$this->view->start_date = $start_date;
				$this->view->end_date = $end_date;
				if(!empty($data["LocationId"])){
					$branch=$query->getLocationName($data["LocationId"]);
					$this->view-> branch = $branch;
				}
			}
			else {
				Application_Form_FrmMessage::message("End Date Must Greater Then Start Date");
			}
		}
		$frm = new Application_Form_FrmReport();
		$form_search=$frm->salseReport();
		Application_Model_Decorator::removeAllDecorator($form_search);
		$this->view->form_salse = $form_search;
		
	}
	
	public function rptpurchaseAction()//purchase report
	{
		if($this->getRequest()->isPost()){
			$data = $this->getRequest()->getPost();
			$start_date = $data["start_date"];
			$end_date = $data["end_date"];
	
			if(strtotime($end_date)+86400 > strtotime($start_date)) {
				$query = new report_Model_DbQuery();
	
				//$vendor_sql .= " AND p.date_order BETWEEN '$start_date' AND '$end_date'";
				$getSaleItem = $query->getPurchaseItem($data);
				$this->view->getsales_item = $getSaleItem;
				$this->view->start_date = $start_date;
				$this->view->end_date = $end_date;
				if(!empty($data["LocationId"])){
					$branch=$query->getLocationName($data["LocationId"]);
					$this->view-> branch = $branch;
				}
			}
			else {
				Application_Form_FrmMessage::message("End Date Must Greater Then Start Date");
			}
		}
		$frm = new Application_Form_FrmReport();
		$form_search=$frm->salseReport();
		Application_Model_Decorator::removeAllDecorator($form_search);
		$this->view->form_salse = $form_search;
	
	}
	
	//for view-report /27/8/13
	public function veiwReportAction(){
		$this->_helper->layout->disableLayout();
		
		
	}	
	public function printReportAction(){
		$this->_helper->layout->disableLayout();
	}
	public function index1Action(){
		
	}
	public  function monthAction(){
		
	}
	
	
}